package com.example.myblog.exception;

import com.example.myblog.result.BaseError;

/**
 * @author 叶兴
 */
public class BaseException extends Exception implements BaseError {
    private BaseError baseError;

    public BaseException(BaseError baseError) {
        super(baseError.getErrorMsg());
        this.baseError = baseError;
    }

    public BaseException(String message, BaseError baseError) {
        super();
        this.baseError.setErrorMsg(message);
        this.baseError = baseError;
    }

    @Override
    public int getErrorCode() {
        return this.baseError.getErrorCode();
    }

    @Override
    public String getErrorMsg() {
        return this.baseError.getErrorMsg();
    }

    @Override
    public BaseError setErrorMsg(String message) {
        this.baseError.setErrorMsg(message);
        return this;
    }
}
